﻿// --- Copyright (c) 2006-2008 Stefan Kyntchev ---
// This software is written and copyrighted by Stefan Kyntchev 
// and BeyondPod Team members. All rights are reserved.
// Author contact: support@beyondpod.mobi
// ------------------------------------------------------------------------
// This file is part of BeyondPod RSS Feed Reader and Podcast manager
// (www.codeplex.com/BeyondPod) 
// BeyondPod is free software: you can redistribute it and/or modify 
// it under the terms of the GNU General Public License as published by 
// the Free Software Foundation, either version 3 of the License, or 
// (at your option) any later version. 
//  
// BeyondPod is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
// GNU General Public License for more details. 
//  
// You should have received a copy of the GNU General Public License
// along with BeyondPod. If not, see <http://www.gnu.org/licenses/>
// ------------------------------------------------------------------------
// COPYRIGHT NOTICE: This copyright notice may NOT be removed, obscured or modified 
// without written consent from the author.
// --- End copyright notice --- 


using System;
using System.IO;
using System.Windows.Forms;

namespace svs.Mobile.BeyondScheduler.Core.Objects.Operations.OperationUIs
{
	public partial class OperationStartApplicationUI : Form
	{
		public OperationStartApplicationUI()
		{
			InitializeComponent();
		}

		private void mnuDone_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.OK;
			Close();
		}

		private void mnuCancel_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Cancel;
			Close();
		}

		private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if (DialogResult == DialogResult.OK)
			{
				if (string.IsNullOrEmpty(Application.Text) || !File.Exists(Application.Text))
				{
					MessageBox.Show("The application path does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
					                MessageBoxDefaultButton.Button1);
					e.Cancel = false;
				}
			}
		}

		private void OnBrowse(object sender, EventArgs e)
		{
			OpenNETCF.Windows.Forms.OpenFileDialog dlg = new OpenNETCF.Windows.Forms.OpenFileDialog();
			dlg.InitialDirectory = @"\Windows\Start Menu\Programs\";
			dlg.Title = "Select Application";
			if (dlg.ShowDialog() == DialogResult.OK)
				Application.Text = dlg.FileName;
		}
	}
}